
import { message } from 'antd'
import { useAxiosWebPost } from './axios'
import { useForm } from './useForm'
import { useModal } from './useModal'
export const useChangePassword = () => {
    const { fetch } = useAxiosWebPost('imeepos/core/user/change_password')
    const { props: modalProps, setOpen } = useModal('修改密码')
    const { props: formProps } = useForm([
        { title: '旧密码', dataIndex: 'password', valueType: 'password', formItemProps: { rules: [{ required: true, message: '必填' }] } },
        { title: '新密码', dataIndex: 'newPassword', valueType: 'password', formItemProps: { rules: [{ required: true, message: '必填' }] } },
        { title: '确认密码', dataIndex: 'reNewPassword', valueType: 'password', formItemProps: { rules: [{ required: true, message: '必填' }] } }
    ], async (values) => {
        return fetch(values).then((res) => {
            if (res.success) {
                message.success(`密码修改成功`)
                setOpen(false)
            }
        })
    })
    return {
        modal: modalProps,
        form: formProps,
        setOpen
    }
}